package edu.jd.movieplatform.admin.a_info;

import edu.jd.movieplatform.common.CommonService;
import edu.jd.movieplatform.common.CurrentManager;
import edu.jd.movieplatform.common.MTokenUtils;
import edu.jd.movieplatform.common.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/admin/a_info")
public class a_InfoAPI {
    @Resource
    private a_InfoService a_infoService;

    @Resource
    private CommonService commonService;

    @GetMapping("")
    public Result a_infoList(@RequestHeader("Token") String token){
        CurrentManager currentManager = MTokenUtils.getUserInfo(token,commonService);
        a_InfoDto dto = new a_InfoDto();
        dto.setM_id(currentManager.getM_id());
        Map<String,Object> page = a_infoService.getInfo(dto);
        return Result.success(page);
    }


    @PutMapping("")
    public Result infoUpd(@RequestBody a_InfoDto dto){
        dto.setM_sex(dto.getM_sex().equals("男")?"1":"0");
        a_infoService.updInfo(dto);
        return Result.success();
    }
}
